<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/3/25
 * Time: 20:03
 */

namespace front\modules\app\controllers;

use backfeed\services\CommentService;
use common\helpers\ReturnHelper;
use front\controllers\RestBaseController;
use goods\services\CollectionService;
use users\services\UserService;
use yii\helpers\ArrayHelper;

class MyController extends RestBaseController
{

    /**
     * 我的
     * @return array
     */
    public function actionIndex()
    {
        $params = \yii::$app->request->post();
        $data = [];
        $data['comm'] = 0;
        $comm = CommentService::getCount($params);
        if($comm['code'] == 0){
            $data['comm'] = $comm['result']['count'];
        }
        //当前用户收藏的商品数量
        $data['coll'] = CollectionService::getCollectionCount(null, $params['user_id']);
        $user = UserService::getUserInfo($params['user_id'], 1);
        $user = ArrayHelper::toArray($user['result']);
        if(empty($user)){
            return ReturnHelper::error('该用户不存在');
        }
        $data['name'] = empty($user['nickname']) ? $user['mobile'] : $user['nickname'];
        $data['shop_id'] = $this->shop_id;
//        $data['photo'] = $this->photo;
        return ReturnHelper::success('success', $data);
    }

}